package com.xindaoapp.happypet.shop.ui;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.graphics.Paint;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.xindao.photonics.fragments.manager.BaseFragment;
import com.xindaoapp.happypet.R;
import com.xindaoapp.happypet.activity.BrandActivity;
import com.xindaoapp.happypet.activity.CatListItem;
import com.xindaoapp.happypet.adapter.XinDaoBaseAdapter;
import com.xindaoapp.happypet.bean.BrandBean;
import com.xindaoapp.happypet.bean.HomeBanner;
import com.xindaoapp.happypet.bean.Product;
import com.xindaoapp.happypet.bean.SecondClass;
import com.xindaoapp.happypet.bean.SecondClass.SencondClassInfo;
import com.xindaoapp.happypet.utils.CommonParameter;
import com.xindaoapp.happypet.utils.CommonUtil;
import com.xindaoapp.happypet.utils.Constants;
import com.xindaoapp.happypet.utils.IRequest;
import com.xindaoapp.happypet.view.MyGridView;
import com.xindaoapp.happypet.view.RollViewPager2;
import com.xindaoapp.happypet.view.RoundImageView2;

public class ShopFragment extends BaseFragment {

    private PullToRefreshListView mListView;
    private String currentPositionId = "";// 当前分类的Banner分类ID
    private String currentParentID = "";// 当前分类的Banner分类ID
    private ViewPager viewpager;
    private final List<String> imageUrlList = new ArrayList<String>();
    private MyGridView vIconGridview;
    private MyGridView vTextGridview;
    private final List<SencondClassInfo> sencondClasses =
            new ArrayList<SecondClass.SencondClassInfo>();
    private final List<SencondClassInfo> newSencondClasses =
            new ArrayList<SecondClass.SencondClassInfo>();
    private IconAdapter iconAdapter;
    private TextAdapter textAdapter;
    // private View divider_line;
    private LinearLayout ll_brand;
    private LinearLayout mViewPager;
    private RelativeLayout xPagerRootView;
    private ArrayList<View> dotLists;
    private TextView mtvDescription;
    private LinearLayout mllPoints;

    private String brandID, catID;

    public static ShopFragment newInstance(String currentItem) {
        String curId = "";
        String curParentID = "";
        if ("喵星人".equals(currentItem)) {
            curId = "20";
            curParentID = "99";
        } else if ("汪星人".equals(currentItem)) {
            curId = "19";
            curParentID = "100";
        }
        ShopFragment shopFragment = new ShopFragment();
        Bundle bundle = new Bundle();
        bundle.putString("currentPositionId", curId);
        bundle.putString("currentParentID", curParentID);
        shopFragment.setArguments(bundle);
        return shopFragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_shop, container, false);
        mListView = (PullToRefreshListView) rootView.findViewById(R.id.listview);
        return rootView;
    }


    @Override
    protected void initViews(View view) {
        super.initViews(view);

        Bundle arguments = getArguments();
        if (arguments != null) {
            currentPositionId = arguments.getString("currentPositionId");
            currentParentID = arguments.getString("currentParentID");
        }

        View headerView = View.inflate(getActivity(), R.layout.layout_header_shop, null);
        // viewpager = (ViewPager) headerView.findViewById(R.id.viewpager);

        mViewPager = (LinearLayout) headerView.findViewById(R.id.viewpager1);
        xPagerRootView = (RelativeLayout) headerView.findViewById(R.id.xlistview_viewpage1);
        xPagerRootView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                CommonParameter.sScreenWidth * 284 / 640));

        mViewPager.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                CommonParameter.sScreenWidth * 284 / 640));

        mtvDescription = (TextView) headerView.findViewById(R.id.tv_image_description1);
        headerView.findViewById(R.id.rl_bottom).getBackground().setAlpha(100);
        mllPoints = (LinearLayout) headerView.findViewById(R.id.ll_points1);
        mllPoints.setVisibility(View.GONE);
        // divider_line = headerView.findViewById(R.id.divider_line);
        ll_brand = (LinearLayout) headerView.findViewById(R.id.ll_brand);
        ll_brand.setWeightSum(3);

        // viewpager.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
        // (int) ((float) CommonParameter.sScreenWidth / 600 * 245)));

        vIconGridview = (MyGridView) headerView.findViewById(R.id.gridview);
        vTextGridview = (MyGridView) headerView.findViewById(R.id.gridview_more);


        vIconGridview.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
                SecondClass.SencondClassInfo sInfo =
                        (SecondClass.SencondClassInfo) arg0.getAdapter().getItem(position);


                if (position < 7) {
                    Intent intent = new Intent(mActivity, CatListItem.class);
                    intent.putExtra("catID", sInfo.cat_id);
                    intent.putExtra("catName", sInfo.cat_name);
                    startActivity(intent);


                    // Intent intent = new Intent(mActivity, GoodsListActivity.class);
                    // intent.putExtra("type", sInfo.cat_name);
                    // intent.putExtra("catID", sInfo.cat_id);
                    // startActivity(intent);

                } else {
                    if (vTextGridview.getVisibility() == View.VISIBLE) {
                        // divider_line.setVisibility(View.GONE);
                        vTextGridview.setVisibility(View.GONE);
                    } else {
                        // divider_line.setVisibility(View.VISIBLE);
                        vTextGridview.setVisibility(View.VISIBLE);
                    }
                }
            }
        });
        vTextGridview.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
                SecondClass.SencondClassInfo sInfo =
                        (SecondClass.SencondClassInfo) arg0.getAdapter().getItem(position);

                Intent intent = new Intent(mActivity, CatListItem.class);
                intent.putExtra("catID", sInfo.cat_id);
                intent.putExtra("catName", sInfo.cat_name);
                startActivity(intent);



                // Intent intent = new Intent(mActivity, GoodsListActivity.class);
                //
                // intent.putExtra("type", sInfo.cat_name);
                // intent.putExtra("catID", sInfo.cat_id);
                // startActivity(intent);
            }
        });


        iconAdapter = new IconAdapter();
        vIconGridview.setAdapter(iconAdapter);
        textAdapter = new TextAdapter();
        vTextGridview.setAdapter(textAdapter);

        mListView.getRefreshableView().addHeaderView(headerView);
        mListView.getRefreshableView().setAdapter(null);

        mListView.setOnRefreshListener(new OnRefreshListener<ListView>() {
            @Override
            public void onRefresh(PullToRefreshBase<ListView> refreshView) {
                onLoadData();
            }

        });
    }

    @Override
    protected void initEvents() {
        super.initEvents();
    }

    @Override
    protected void onLoadData() {
        super.onLoadData();
        getSecndeData();

        /******************** 获取Banner数据 ************************/
        getMoccaApi().getShopBanners(currentPositionId, new IRequest<List<HomeBanner>>() {

            @Override
            public void request(List<HomeBanner> t) {
                mListView.onRefreshComplete();
                if (t != null) {
                    if (t != null && t.size() > 0) {
                        prepareViewPage(mActivity, t);
                    }
                }
            }
        });

        /******************** 获取品牌数据 ************************/
        getMoccaApi().getBrandInfo(new IRequest<BrandBean>() {

            @Override
            public void request(final BrandBean t) {
                if (t != null && t.data != null && t.data.info.size() > 0) {

                    LinearLayout view1 =
                            (LinearLayout) View.inflate(mActivity, R.layout.item_pro_image, null);
                    ImageView[] imageViews =
                            new ImageView[] {(ImageView) view1.findViewById(R.id.iv_image1),
                                    (ImageView) view1.findViewById(R.id.iv_image2),
                                    (ImageView) view1.findViewById(R.id.iv_image3)};
                    int i = 0;
                    for (ImageView iv : imageViews) {
                        android.view.ViewGroup.LayoutParams lp = iv.getLayoutParams();
                        lp.width =
                                (CommonParameter.sScreenWidth - CommonUtil.dp2px(mActivity, 20)) / 3 - 20;
                        lp.height =
                                (CommonParameter.sScreenWidth - CommonUtil.dp2px(mActivity, 20)) / 3 - 20;
                        iv.setLayoutParams(lp);
                        if (CommonParameter.isLoadImg && t.data != null && t.data.info != null) {
                            ImageLoader.getInstance().displayImage(t.data.info.get(i).brand_logo,
                                    iv);
                            i++;
                        }


                        iv.setOnClickListener(new OnClickListener() {

                            @Override
                            public void onClick(View v) {
                                Intent i = new Intent(getActivity(), BrandActivity.class);
                                startActivity(i);
                            }
                        });
                    }
                    i = 0;

                    // android.view.ViewGroup.LayoutParams lp2 = iv2.getLayoutParams();
                    // android.view.ViewGroup.LayoutParams lp3 = iv3.getLayoutParams();
                    //
                    //
                    // lp2.width =
                    // (CommonParameter.sScreenWidth - CommonUtil.dp2px(mActivity, 20)) / 3 - 20;
                    // lp2.height =
                    // (CommonParameter.sScreenWidth - CommonUtil.dp2px(mActivity, 20)) / 3 - 20;
                    // lp3.width =
                    // (CommonParameter.sScreenWidth - CommonUtil.dp2px(mActivity, 20)) / 3 - 20;
                    // lp3.height =
                    // (CommonParameter.sScreenWidth - CommonUtil.dp2px(mActivity, 20)) / 3 - 20;

                    // iv1.setLayoutParams(lp1);
                    // iv2.setLayoutParams(lp2);
                    // iv3.setLayoutParams(lp3);
                    //
                    // if (CommonParameter.isLoadImg && t.data != null && t.data.info != null) {
                    // if (t.data.info.size() == 1) {
                    // ImageLoader.getInstance().displayImage(t.data.info.get(0).brand_logo,
                    // iv1);
                    // iv2.setVisibility(View.GONE);
                    // iv3.setVisibility(View.GONE);
                    // } else if (t.data.info.size() == 2) {
                    // ImageLoader.getInstance().displayImage(t.data.info.get(0).brand_logo,
                    // iv1);
                    // ImageLoader.getInstance().displayImage(t.data.info.get(1).brand_logo,
                    // iv2);
                    // iv3.setVisibility(View.GONE);
                    // } else {
                    // ImageLoader.getInstance().displayImage(t.data.info.get(0).brand_logo,
                    // iv1);
                    // ImageLoader.getInstance().displayImage(t.data.info.get(1).brand_logo,
                    // iv2);
                    // ImageLoader.getInstance().displayImage(t.data.info.get(2).brand_logo,
                    // iv3);
                    // }
                    // // iv1.setImageResource(R.drawable.loginsign1);
                    // } else {
                    // iv1.setImageResource(R.drawable.picture_loading);
                    // iv2.setImageResource(R.drawable.picture_loading);
                    // iv3.setImageResource(R.drawable.picture_loading);
                    // }
                    //
                    // iv1.setOnClickListener(new OnClickListener() {
                    //
                    // @Override
                    // public void onClick(View arg0) {
                    // Intent intent = new Intent(mActivity, CatListItem.class);
                    // intent.putExtra("catID", t.data.info.get(0).brand_id);
                    // intent.putExtra("catName", t.data.info.get(0).brand_name);
                    // startActivity(intent);
                    //
                    // // // TODO Auto-generated method stub
                    // // Intent intent = new Intent(mActivity, GoodsListActivity.class);
                    // //
                    // // intent.putExtra("type", t.data.info.get(0).brand_name);
                    // // intent.putExtra("brandID", t.data.info.get(0).brand_id);
                    // // startActivity(intent);
                    // }
                    // });
                    // iv2.setOnClickListener(new OnClickListener() {
                    //
                    // @Override
                    // public void onClick(View arg0) {
                    // Intent intent = new Intent(mActivity, CatListItem.class);
                    // intent.putExtra("catID", t.data.info.get(1).brand_id);
                    // intent.putExtra("catName", t.data.info.get(1).brand_name);
                    // startActivity(intent);
                    //
                    // // TODO Auto-generated method stub
                    // // Intent intent = new Intent(mActivity, GoodsListActivity.class);
                    // //
                    // // intent.putExtra("type", t.data.info.get(1).brand_name);
                    // // intent.putExtra("brandID", t.data.info.get(1).brand_id);
                    // // startActivity(intent);
                    // }
                    // });
                    // iv3.setOnClickListener(new OnClickListener() {
                    //
                    // @Override
                    // public void onClick(View arg0) {
                    // Intent intent = new Intent(mActivity, CatListItem.class);
                    // intent.putExtra("catID", t.data.info.get(2).brand_id);
                    // intent.putExtra("catName", t.data.info.get(2).brand_name);
                    // startActivity(intent);
                    //
                    // // TODO Auto-generated method stub
                    // // Intent intent = new Intent(mActivity, GoodsListActivity.class);
                    // //
                    // // intent.putExtra("type", t.data.info.get(2).brand_name);
                    // // intent.putExtra("brandID", t.data.info.get(2).brand_id);
                    // // startActivity(intent);
                    // }
                    // });

                    ll_brand.addView(view1);


                }
            }
        });

        /******************** 获取新品列表数据 ************************/
        getMoccaApi().getNewGoods(new IRequest<List<Product>>() {

            @Override
            public void request(List<Product> t) {
                if (t != null && t.size() > 0) {
                    mListView.getRefreshableView().setAdapter(
                            new ShopAdapter(mActivity, t, Constants.PAGE_SIZE,
                                    R.layout.good_common_item_1, R.layout.item_loading));
                }
            }
        });

    }


    private void getSecndeData() {
        /******************** 获取二级分类数据 ************************/
        getMoccaApi().getSecondClasses(currentParentID, new IRequest<SecondClass>() {
            @Override
            public void request(SecondClass t) {
                if (t != null && t.data != null) {
                    sencondClasses.clear();
                    if (t.data.size() > 7) {
                        for (int i = 0; i < 8; i++) {
                            sencondClasses.add(t.data.get(i));
                        }
                    } else if (t.data.size() > 0) {
                        sencondClasses.addAll(t.data);
                    } else {

                    }
                    iconAdapter.notifyDataSetChanged();
                    // if (sencondClasses.size() > 4) {
                    // vIconGridview.setLayoutParams(new LinearLayout.LayoutParams(
                    // LayoutParams.MATCH_PARENT,
                    // (int) ((float) CommonParameter.sScreenWidth / 600 * 320)));
                    // }
                    if (t.data.size() > 7) {
                        newSencondClasses.clear();
                        for (int i = 7; i < t.data.size(); i++) {
                            newSencondClasses.add(t.data.get(i));
                        }
                        textAdapter.notifyDataSetChanged();
                        // if (newSencondClasses.size() > 4) {
                        // // vTextGridview.setLayoutParams(new LinearLayout.LayoutParams(
                        // // LayoutParams.MATCH_PARENT,
                        // // (int) ((float) CommonParameter.sScreenWidth / 600 * 200)));
                        // }
                    }
                    onDataArrived(true);
                } else {
                    onDataArrived(false);
                }
            }
        });
    }


    class ShopAdapter extends XinDaoBaseAdapter<Product> {

        public ShopAdapter(Context context, List<Product> iniData, int pageSize, int res,
                int loadingRes) {
            super(context, iniData, pageSize, res, loadingRes);
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent, final Product value) {
            ViewHolder holder = (ViewHolder) convertView.getTag();
            if (holder == null) {
                holder = new ViewHolder();
                holder.good_pic = (ImageView) convertView.findViewById(R.id.good_pic);
                holder.good_name = (TextView) convertView.findViewById(R.id.good_name);
                holder.good_shop_price = (TextView) convertView.findViewById(R.id.good_shop_price);
                holder.good_market_price =
                        (TextView) convertView.findViewById(R.id.good_market_price);
                holder.good_sell = (TextView) convertView.findViewById(R.id.good_sell);
                holder.good_surplus = (TextView) convertView.findViewById(R.id.good_surplus);
                holder.goods_comment = (TextView) convertView.findViewById(R.id.goods_comment);
                holder.good_dazhe = (TextView) convertView.findViewById(R.id.good_dazhe);
                convertView.setTag(holder);
            }


            holder.good_name.setText(value.goods_name);
            holder.good_shop_price.setText(value.shop_price + "");
            holder.good_market_price.setText("￥" + value.market_price);
            holder.good_market_price.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
            holder.good_sell.setText(value.sold_number);
            holder.good_surplus.setText(value.goods_number + "");
            holder.goods_comment.setText(value.comment_star + "");
            if (value.goods_thumb != null) {
                ImageLoader.getInstance().displayImage(value.goods_thumb, holder.good_pic);
            } else {
                holder.good_pic.setBackgroundResource(R.drawable.picture_loading);
            }
            float a = 0;
            if (!TextUtils.isEmpty(value.market_price)) {
                a = (Float.valueOf(value.shop_price) / Float.valueOf(value.market_price)) * 10;
            }
            holder.good_dazhe.setText(formatDaZhe(a) + "折");
            convertView.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(getActivity(), ProductDetailActivity.class);
                    intent.putExtra(Constants.KEY_GOODS_ID, value.goods_id);
                    startActivity(intent);
                }
            });

            return convertView;
        }
    }

    private String formatDaZhe(Float a) {
        DecimalFormat df = new DecimalFormat("0.0");
        return df.format(a);
    }

    static class ViewHolder {
        ImageView good_pic;
        TextView good_name;
        TextView good_shop_price;
        TextView good_market_price;
        TextView good_sell;
        TextView good_surplus;
        TextView goods_comment;
        TextView good_dazhe;


        ImageView icon;
        TextView title;
        TextView price;
        TextView shop_price;
        TextView zhekou;
        TextView cat_name;
        RoundImageView2 iv_item_list;
    }

    public class TextAdapter extends BaseAdapter {

        @Override
        public int getCount() {
            return newSencondClasses.size();
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            convertView = View.inflate(mActivity, R.layout.left_menu_text_list, null);
            TextView tv_text = (TextView) convertView.findViewById(R.id.tv_text);
            tv_text.setText(newSencondClasses.get(position).cat_name);
            return convertView;
        }

        @Override
        public Object getItem(int position) {
            return newSencondClasses.get(position);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }
    }


    public class IconAdapter extends BaseAdapter {
        @Override
        public int getCount() {
            return sencondClasses.size();
        }

        @Override
        public View getView(final int position, View convertView, ViewGroup parent) {
            ViewHolder holder;
            if (convertView == null) {
                holder = new ViewHolder();
                convertView = View.inflate(mActivity, R.layout.left_nemu_list_shop, null);
                holder.iv_item_list = (RoundImageView2) convertView.findViewById(R.id.iv_item_list);
                holder.cat_name = (TextView) convertView.findViewById(R.id.tv_item_list);
                convertView.setTag(holder);
            } else {
                holder = (ViewHolder) convertView.getTag();
            }
            SencondClassInfo sInfo = sencondClasses.get(position);
            if (position < 7) {
                if (!TextUtils.isEmpty(sInfo.img_url) && CommonParameter.isLoadImg) {
                    ImageLoader.getInstance().displayImage(sInfo.img_url, holder.iv_item_list);
                } else {
                    holder.iv_item_list.setImageResource(R.drawable.picture_loading);
                }
                holder.cat_name.setText(sInfo.cat_name);
            } else if (position == 7) {
                holder.cat_name.setText("更多");
                holder.iv_item_list.setBackgroundResource(R.drawable.jia_press);
            }

            return convertView;
        }

        @Override
        public Object getItem(int position) {
            return sencondClasses.get(position);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }
    }

    public void prepareViewPage(final Context context, final List<HomeBanner> list) {
        List<String> titleList = new ArrayList<String>();
        List<String> imageUrlList = new ArrayList<String>();
        for (HomeBanner homeBanner : list) {
            titleList.add(homeBanner.getTitle());
            imageUrlList.add(homeBanner.getCoverpath());
        }
        initDots(list.size());
        RollViewPager2 rollViewPager =
                new RollViewPager2(context, dotLists, R.drawable.banner_normal,
                        R.drawable.banner_selected, new RollViewPager2.MyOnTouchCllickCallBack() {
                            @Override
                            public void OnTouchCllick(int position) {
                                String type = list.get(position % list.size()).getType();
                                Intent intent = new Intent(mActivity, CatListItem.class);
                                if ("20".equals(currentPositionId)) {// 喵星人
                                    intent.putExtra("catID", 101);
                                    intent.putExtra("catName", "猫咪主粮");
                                } else if ("19".equals(currentPositionId)) {// 汪星人
                                    intent.putExtra("catID", 113);
                                    intent.putExtra("catName", "狗狗主粮");
                                }
                                startActivity(intent);


                                // if (type.equals("web")) {// 跳转到详情
                                // Intent intent1 =
                                // new Intent(context, HomeBannerDetailActivity.class);
                                // intent1.putExtra("url", list.get(position % list.size())
                                // .getLink());
                                // context.startActivity(intent1);
                                // getActivity().overridePendingTransition(
                                // R.anim.new_dync_in_from_right,
                                // R.anim.new_dync_out_to_left);
                                // } else if (type.equals("appthread")) {// 跳转到帖子详情
                                // Intent intent2 = new Intent(context, PostDetailActivity.class);
                                // intent2.putExtra(Constants.KEY_POST_TID,
                                // list.get(position % list.size()).getLink());
                                // context.startActivity(intent2);
                                // getActivity().overridePendingTransition(
                                // R.anim.new_dync_in_from_right,
                                // R.anim.new_dync_out_to_left);
                                // }
                            }
                        });

        rollViewPager.handler.removeCallbacksAndMessages(null);
        rollViewPager.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                CommonParameter.sScreenWidth * 284 / 640));
        rollViewPager.setTitle(mtvDescription, titleList);
        rollViewPager.setImageUrl(imageUrlList);
        rollViewPager.startRoll();
        mViewPager.removeAllViews();
        mViewPager.addView(rollViewPager);

    }

    private void initDots(int size) {
        dotLists = new ArrayList<View>();
        mllPoints.removeAllViews();
        for (int i = 0; i < size; i++) {
            LinearLayout.LayoutParams layoutParams =
                    new LinearLayout.LayoutParams(CommonUtil.dip2px(mActivity, 5),
                            CommonUtil.dip2px(mActivity, 5));
            layoutParams.setMargins(5, 0, 5, 0);
            // LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(15,
            // 15);
            // lp.leftMargin = 10;

            ImageView m = new ImageView(mActivity);
            // m.setLayoutParams(new LayoutParams(CommonUtil.dip2px(mContext, 3), CommonUtil.dip2px(
            // mContext, 3)));
            if (i == 0) {
                m.setBackgroundResource(R.drawable.banner_selected);
            } else {
                m.setBackgroundResource(R.drawable.banner_normal);
            }
            m.setLayoutParams(layoutParams);
            dotLists.add(m);
            mllPoints.addView(m);
        }
    }

}
